using System;
using System.Configuration;

namespace TimeSheet
{
	/// <summary>
	/// This is a wrapper class that provides access to web.config items, as well
	/// as other common constants (like session variable names).
	/// 
	/// Version: $Id: AppSettings.cs,v 1.2 2004/05/18 15:32:24 jperrin Exp $
	/// 
	/// Date: 
	/// Copyright: 2004, Jeff Perrin
	/// </summary>
	public class AppSettings
	{

		#region Configuration Properties

		/// <summary>
		/// This is the number of days into the future that a staff member
		/// can edit their timesheet.  The most common would be zero (you can't
		/// enter hours for future dates), however if you want to allow
		/// your staff to enter in time for holidays before they leave, you can
		/// change this number to a suitable one.
		/// </summary>
		public static int FutureDateLockSeed
		{
			get{ return Convert.ToInt32( ConfigurationSettings.AppSettings[ "FutureDateLockSeed" ] ); }
		}

		/// <summary>
		/// The number of days into the past that a staff member can edit
		/// their hours.
		/// </summary>
		public static int PastDateLockSeed
		{
			get{ return Convert.ToInt32( ConfigurationSettings.AppSettings[ "PastDateLockSeed" ] ); }
		}

		/// <summary>
		/// This is the error message that is shown when invalid input is entered.
		/// </summary>
		public static string InputErrorMessage
		{
			get{ return ConfigurationSettings.AppSettings[ "InputErrorMessage" ]; }
		}

		/// <summary>
		/// Whether or not staff members can change their hours outside of the specified
		/// LockDate and FutureDateLockSeed.
		/// </summary>
		public static bool IsLocked
		{
			get{ return Convert.ToBoolean( ConfigurationSettings.AppSettings[ "LockNonPeriod" ] ); }
		}

		/// <summary>
		/// The length of the automatically generated passwords.
		/// </summary>
		public static int PasswordLength
		{
			get{ return Convert.ToInt32( ConfigurationSettings.AppSettings[ "PasswordLength" ] ); }
		}
		
		/// <summary>
		/// The location of the staff website. (ie; www2.kanga.ca)
		/// </summary>
		public static string SiteURL
		{
			get{ return ConfigurationSettings.AppSettings[ "SiteURL" ]; }
		}

		/// <summary>
		/// The location of the admin website (ie; www2.kanga.ca/Protected)
		/// </summary>
		public static string AdminURL
		{
			get{ return ConfigurationSettings.AppSettings[ "AdminURL" ]; }
		}

		/// <summary>
		/// The mail server used to send emails.
		/// </summary>
		public static string SmtpServer
		{
			get{ return ConfigurationSettings.AppSettings[ "SmtpServer" ]; }
		}


		/// <summary>
		/// The user-friendly name of the site. (ie; Kanga Timesheet)
		/// </summary>
		public static string SiteName
		{
			get
			{
				return ConfigurationSettings.AppSettings[ "SiteName" ];
			}
		}

		/// <summary>
		/// The e-mail address to which error messages are sent.
		/// </summary>
		public static string AdminEmail
		{
			get{ return ConfigurationSettings.AppSettings[ "AdminEmail" ]; }
		}

		/// <summary>
		/// The number of hours in a workday.  This number is used to calculate
		/// overtime and completion reports.
		/// </summary>
		public static double HoursInDay
		{
			get{ return Convert.ToDouble( ConfigurationSettings.AppSettings[ "HoursInDay" ] ); }
		}

		public static string QueryFile
		{
			get{ return System.Web.HttpContext.Current.Server.MapPath( ConfigurationSettings.AppSettings[ "QueryFile" ] ); }
		}

		#endregion

		#region Session Variables

		public static string AdministratorSessionName
		{
			get{ return "Administrator"; }
		}

		public static string UserSessionName
		{
			get{ return "User"; }
		}

		#endregion

	}
}
